import { createParamDecorator, ExecutionContext, BadRequestException } from '@nestjs/common';

export const ValidateBigInt = createParamDecorator(
  (data: unknown, ctx: ExecutionContext) => {
    const request = ctx.switchToHttp().getRequest();
    const value = request.params[data as string];
    
    try {
      return BigInt(value);
    } catch (error) {
      throw new BadRequestException(`参数 ${data} 必须是有效的数字`);
    }
  },
);